package yc.gg.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.RedisScript;

/**
 * \* User: Fuyue
 * \* Date: 2025/3/10
 * \* Description:
 * \
 */
@Configuration
public class RedisConfig {
    private static StringRedisTemplate staticStringRedisTemplate;

    @Bean
    public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
        StringRedisTemplate template = new StringRedisTemplate();
        template.setConnectionFactory(redisConnectionFactory);
        staticStringRedisTemplate = template;
        return template;
    }

    public static StringRedisTemplate getStaticStringRedisTemplate() {
        return staticStringRedisTemplate;
    }


/*
    @Bean
    public RedisScript<Long> joinRoomScript() {
        Resource scriptSource = new ClassPathResource("scripts/join_room.lua");
        return RedisScript.of(scriptSource, Long.class);
    }

    @Bean
    public RedisScript<Long> dissolveRoomScript() {
        Resource scriptSource = new ClassPathResource("scripts/dissolve_room.lua");
        return RedisScript.of(scriptSource, Long.class);
    }

    @Bean
    public RedisScript<Long> quitRoomScript() {
        Resource scriptSource = new ClassPathResource("scripts/quit_room.lua");
        return RedisScript.of(scriptSource, Long.class);
    }
*/
}